Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support detect selector when there are animation-name defined already #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lxjwlt
Copy link

@lxjwlt lxjwlt commented Oct 7, 2017

support detect selector when the DOM element has css animation-name defined #4

@amorey
Copy link
Member

amorey commented Oct 7, 2017

Hi @lxjwlt - can you explain this feature in more detail? It looks similar to the custom animation-name feature explained here:
https://github.com/muicss/sentineljs#on---add-a-watch-for-new-dom-nodes

@lxjwlt
Copy link
Author

lxjwlt commented Oct 8, 2017

thanks for review.
i want to make it possible to detect element by selector, even if animation-name generated by sentineljs has been overridden. XD
i don't think it is a elegant solution to detect element by custom animation-name node-inserted, it means we should add that name everywhere inner css and make sure we don't miss one.
and it also mess up all selectors:

sentinel.on('!node-inserted', function(el) {
    if (el.matches('.my-div')) {
         // do something...
    } else if (el.matches('.my-div2')) {
        // do something...
    }
});

@amorey
Copy link
Member

amorey commented Oct 8, 2017 via email

@lxjwlt
Copy link
Author

lxjwlt commented Oct 9, 2017

😆as additional test, the changes would not affect the original feature of sentineljs, but it just add watch for all new element. when element animationstart, it would look for the matched selector contained in selectorToAnimationMap, and invokes all callbacks.

example is like this:

<style>
     @keyframes slidein { /*...*/ }
     .my-div { animation-name: slide-in; } 
</style>
<script>
     /* no matter the element has animation-name defined or not, 
         we can wacth it by selector  */
     sentinel.on('.my-div', function(el) { 
         // ...
     });
</script>

@amorey
Copy link
Member

amorey commented Oct 9, 2017

If I understand the code correctly, it looks like this pull request iterates through all CSS selectors on every animationstart event. Is there a way to implement this without iterating through all selectors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants